<?php

/**
 * This is the model class for table "ybkz_products".
 *
 * The followings are the available columns in table 'ybkz_products':
 * @property double $id
 * @property string $name
 * @property double $i_order
 * @property string $feature_img
 * @property string $feature_smallimg
 * @property string $introduction
 * @property string $description
 * @property string $price
 * @property string $discount_price
 * @property string $delivery_fee
 * @property string $online_orderable
 * @property string $recommended
 * @property double $create_time
 * @property double $product_category_id
 * @property string $s_locale
 * @property double $pub_start_time
 * @property double $pub_end_time
 * @property string $published
 * @property string $v_num
 * @property string $for_roles
 * @property string $is_seo
 * @property string $meta_key
 * @property string $meta_desc
 */
class Products extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @param string $className active record class name.
	 * @return Products the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'ybkz_products';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('id, i_order, create_time, product_category_id, pub_start_time, pub_end_time', 'numerical'),
			array('name, feature_img, feature_smallimg', 'length', 'max'=>765),
			array('price, discount_price, delivery_fee', 'length', 'max'=>18),
			array('online_orderable, recommended, published, is_seo', 'length', 'max'=>3),
			array('s_locale, for_roles', 'length', 'max'=>150),
			array('v_num', 'length', 'max'=>20),
			array('introduction, description, meta_key, meta_desc', 'safe'),
			array('name, feature_img', 'required'),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('id, name, i_order, feature_img, feature_smallimg, introduction, description, price, discount_price, delivery_fee, online_orderable, recommended, create_time, product_category_id, s_locale, pub_start_time, pub_end_time, published, v_num, for_roles, is_seo, meta_key, meta_desc', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'id' => 'ID',
			'name' => 'Name',
			'i_order' => 'I Order',
			'feature_img' => 'Feature Img',
			'feature_smallimg' => 'Feature Smallimg',
			'introduction' => 'Introduction',
			'description' => 'Description',
			'price' => 'Price',
			'discount_price' => 'Discount Price',
			'delivery_fee' => 'Delivery Fee',
			'online_orderable' => 'Online Orderable',
			'recommended' => 'Recommended',
			'create_time' => 'Create Time',
			'product_category_id' => 'Product Category',
			's_locale' => 'S Locale',
			'pub_start_time' => 'Pub Start Time',
			'pub_end_time' => 'Pub End Time',
			'published' => 'Published',
			'v_num' => 'V Num',
			'for_roles' => 'For Roles',
			'is_seo' => 'Is Seo',
			'meta_key' => 'Meta Key',
			'meta_desc' => 'Meta Desc',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('id',$this->id);
		$criteria->compare('name',$this->name,true);
		$criteria->compare('i_order',$this->i_order);
		$criteria->compare('feature_img',$this->feature_img,true);
		$criteria->compare('feature_smallimg',$this->feature_smallimg,true);
		$criteria->compare('introduction',$this->introduction,true);
		$criteria->compare('description',$this->description,true);
		$criteria->compare('price',$this->price,true);
		$criteria->compare('discount_price',$this->discount_price,true);
		$criteria->compare('delivery_fee',$this->delivery_fee,true);
		$criteria->compare('online_orderable',$this->online_orderable,true);
		$criteria->compare('recommended',$this->recommended,true);
		$criteria->compare('create_time',$this->create_time);
		$criteria->compare('product_category_id',$this->product_category_id);
		$criteria->compare('s_locale',$this->s_locale,true);
		$criteria->compare('pub_start_time',$this->pub_start_time);
		$criteria->compare('pub_end_time',$this->pub_end_time);
		$criteria->compare('published',$this->published,true);
		$criteria->compare('v_num',$this->v_num,true);
		$criteria->compare('for_roles',$this->for_roles,true);
		$criteria->compare('is_seo',$this->is_seo,true);
		$criteria->compare('meta_key',$this->meta_key,true);
		$criteria->compare('meta_desc',$this->meta_desc,true);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}
}
